import { defHttp } from '@/utils/http/axios';
import { FlowManagerPageList, FlowManagerParams } from '@/api/flow/model/managerModel';

const basePath = '/flow/';
const buildUrl = (url: string) => basePath + url;

enum Api {
  FlowManagerList = 'pageQuery',
  FlowManagerAddOrUpdate = 'addOrUpdate',
  FlowManagerDel = 'deleteById',
  AddFlowChart = 'addFlowChart',
  QueryFlowChart = 'queryFlowChart',
}

export const flowManagerList = (params: FlowManagerParams) =>
  defHttp.post<FlowManagerPageList>({
    url: buildUrl(Api.FlowManagerList),
    params: { page: params.page, pageSize: params.pageSize, t: params },
  });

export const flowManagerAddOrUpdate = (params: any) =>
  defHttp.post({ url: buildUrl(Api.FlowManagerAddOrUpdate), params });

export const flowManagerDel = (id: string) =>
  defHttp.get({ url: buildUrl(Api.FlowManagerDel) + '/' + id });

export const queryFlowChart = (id: string) =>
  defHttp.get({ url: buildUrl(Api.QueryFlowChart) + '/' + id });

export const addFlowChart = (params: any) =>
  defHttp.post({ url: buildUrl(Api.AddFlowChart), params });
